//
//  TopCell.m
//  第六组电影项目
//
//  Created by mini on 14-7-4.
//  Copyright (c) 2014年 www.skedu.com.cn北京尚德智远科技有限公司. All rights reserved.
//

#import "TopCell.h"
#import "TopView.h"
@implementation TopCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.selectionStyle=UITableViewCellSelectionStyleNone;
        self.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_main"]];
        // Initialization code
    }
    return self;
}
-(void)initSubViews
{
    int x= (kDeviceWidth - 270)/4.0;
    for (int i=0; i<3; i++)
    {
        TopView *topView=(TopView *)[self.contentView viewWithTag:101+i];
        [topView removeFromSuperview];
    }

    for (int i=0; i<_imagesArray.count; i++)
    {
        TopView *topView=[[TopView alloc]initWithFrame:CGRectMake(x + i * (x + 90),20, 90, 130)];
        topView.tag=101+i;
        [self.contentView addSubview:topView];
        topView.hidden=YES;
        //x+=100;
    }
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    [self initSubViews];
    
    for (int i=0; i<_imagesArray.count; i++)
    {
        TopView *topView=(TopView *)[self.contentView viewWithTag:101+i];
        topView.topModel=_imagesArray[i];
        topView.hidden=NO;
    }
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
